<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'login_form_check.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
     4、登录表单的验证<br>
    <!-- JavaScript 简称：js 是一种弱类型的语言脚本
    var a=0;
    html+js+css -->

    <script type="text/javascript">
//    var a=0;
    //调试js有两种方法：一种叫alert，弹出框。一种叫命令行。
//    alert(a);//打印基本数值的时候没有区别，但是打印对象的时候，
    //alert[Object Object]
//    console.log(a);
    //js除了基本写法以外，还可以写方法
    
    function login()
    {
    	//获取到form
    	var form1=document.getElementById("loginform");
    	var name=document.getElementById("txt_name1").value;
    	var pwd=document.getElementById("txt_pwd1").value;
    	console.log(name);
    	if((name=="wbx")&&(pwd=="aaa"))
    		{
//    		console.log(1);
        	form1.submit();
    		}
    	else
    	{
//    		console.log(2);
    		window.open("error.jsp");
    	}
    }
    </script>
    <form id="loginform" action="./result1.jsp">
    账号：<input id="txt_name1" name="txt_name" type="text"value=""><br>
    密码：<input id="txt_pwd1" name="txt_pwd" type="password" value=""><br>
    <input type="button" value="登录" onclick="login()">
    </form>
  </body>
</html>
